package com.justgame.project.cloud.common.query;

import com.justgame.project.cloud.common.util.ArrayUtils;
import org.springframework.stereotype.Component;

/**
 * 处理父级
 */
@Component
public class QueryParentHandler implements Query.QueryHandler {
    @Override
    public void handle(Query query) {
        if (ArrayUtils.notEmpty(query.getJoinQueries())){
            for (Query joinQuery : query.getJoinQueries()) {
                joinQuery.setMaster(query.getMaster());
                joinQuery.setParent(query);
                handle(joinQuery);
            }
        }
    }

    @Override
    public int sort() {
        return 1;
    }
}
